<?php 
class SwfHelper {
	public static function getInfoSwf($url){
		$rq = sfContext::getInstance()->getRequest();
		$info = getimagesize(($rq->isSecure()?'https://':'http://').$_SERVER['HTTP_HOST'].$url);
		$rt = array(
					'width'	=> intval($info[0]),
					'height'=> intval($info[1]),
					'depth' => intval($info[2])
				);
		return $rt;
	}
	public static function setting($info = array(), $maxWith = 10, $maxHeight = 10){
		if(intval($info['width'])>$maxWith && $maxWith > 0){
			$info['height']	= intval(intval($info['height'])*intval($maxWith)/intval($info['width']));
			$info['width']	= $maxWith;
		}
		if(intval($info['height'])>$maxHeight && $maxHeight > 0){
			$info['width']	= intval(inval($info['width'])*intval($maxHeight)/intval($info['height']));
			$info['height']	= $maxHeight;
		}
		return $info;
	}
	public static function printSWF($data = array()){
		$str = '<object type="application/x-shockwave-flash" data="'.$data['path'].'" width="'.$data['width'].'" height="'.$data['height'].'">'
				.'<param name="movie" value="'.$data['path'].'" />'
				.'<param name="AllowScriptAccess" value="always">'
				.'<param name="quality" value="high" />'
				.'<param name="wmode" value="'.$data['wmode'].'" />'
				.'<param name="swfversion" value="8.0.35.0" />'
				.'<param name="FlashVars" value="'.$data['flashvars'].'">'
				.'<param name="expressinstall" value="/js/ulti/flash-scripts/expressInstall.swf" />'
				.'<embed src="'.$data['path'].'" flashvars="'.$data['flashvars'].'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" play="true" loop="true" wmode="'.$data['wmode'].'" allowscriptaccess="always" width="'.$data['width'].'" height="'.$data['height'].'">'
				.'</object>';
		return $str;
	}
}